# -*- coding: utf-8 -*-
"""
Author:duan
Date: 2021/2/27 15:10
"""
# 生产者消费者模式
# 生产者
import pika

credentials = pika.PlainCredentials('guest', 'guest')
# rabbitmq队列账号密码
connection = pika.BlockingConnection(pika.ConnectionParameters(host='127.0.0.1', credentials=credentials))
# 连接配置：主要包括host、port（默认15672）、credentials（登录用户名密码）
channel = connection.channel()
# 创建一个连接通道
channel.queue_declare(queue='aaa')
# 声明一个名为aaa的队列
channel.basic_publish(exchange='', routing_key='aaa', body='this is a msg!')
# 往aaa队列发送一条消息
connection.close()
#关闭连接
